Skip to content

[#9015] improvement(lance-rest): Add UTs and ITs for Lance rest table operations#9016

Merged
yuqi1129 merged 14 commits intoapache:branch-lance-namepspace-devfrom
yuqi1129:issue_9015
Nov 5, 2025
Merged

[#9015] improvement(lance-rest): Add UTs and ITs for Lance rest table operations#9016
yuqi1129 merged 14 commits intoapache:branch-lance-namepspace-devfrom
yuqi1129:issue_9015

Conversation

@yuqi1129
Copy link
Copy Markdown
Contributor

@yuqi1129 yuqi1129 commented Nov 4, 2025

What changes were proposed in this pull request?

Add ITs for lance rest service and test lance table operations.

Why are the changes needed?

To make code robust

Fix: #9015

Does this PR introduce any user-facing change?

N/A.

How was this patch tested?

It's self a test.

Comment thread lance/lance-rest-server/src/test/resources/log4j2.properties Outdated
@yuqi1129 yuqi1129 requested a review from mchades November 4, 2025 14:45
@yuqi1129 yuqi1129 self-assigned this Nov 4, 2025
@yuqi1129 yuqi1129 added the upload log Always upload container log label Nov 5, 2025
Comment on lines 290 to 292
if (!store.delete(ident, Entity.EntityType.TABLE)) {
throw new RuntimeException("Failed to drop Lance table: " + ident.name());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The false means "failed to store" or "the table not existed"? If the latter, it should return false, not throwing an exception.

The semantics are misleading; you need to confirm with @mchades .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Generic lakehouse will return false if the table not existed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, the current code organization scatters the logic for table operations between GenericLakehouseCatalogOperation and LanceCatalogOperation, which reduces code readability (you need to pay attention to both code logics when operating Lance tables) and introduces some repetitive operations (such as repeatedly gettingTable from store), I think we should consider this issue in our future refactoring.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why do you call store.get twice?

The code here is confused; both the caller and callee will access the DB, and the callee handles some exceptions, but some rely on the caller.

The lance should only focus on lance-specific logic, whereas the generic lakehouse operation should only focus on the metadata-related CRUD operations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, the current code organization scatters the logic for table operations between GenericLakehouseCatalogOperation and LanceCatalogOperation, which reduces code readability (you need to pay attention to both code logics when operating Lance tables) and introduces some repetitive operations (such as repeatedly gettingTable from store), I think we should consider this issue in our future refactoring.

I agree, the implementation is not good, it messes with different logic, and doesn't clearly separate the responsibilities.

Comment on lines 294 to 295
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remembered that @youngyjd mentioned that they don't want to access the storage. How do you handle this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dataset.drop lies in the purgeTable operation, and for deregisterTable I use dropTable, which will not remove lance data.

Comment on lines +528 to +529
throw new UnsupportedOperationException(
"Describing specific table version is not supported.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which exception and http code will be converted for this UnsupportedOperationException?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop operations will be done in GenericLakehouseCatalogOperations#drop and code will not reach lance#drop.
Another point is that we do not support drop tables in LRS currently.

entry -> {
map.put(entry.getKey(), entry.getValue().asText());
});
return map;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd better define a helper function for this, and clearly describe why do you implement like this (not leave the comment here).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@yuqi1129
Copy link
Copy Markdown
Contributor Author

yuqi1129 commented Nov 5, 2025

All resolved.


@Override
public DescribeTableResponse describeTable(String tableId, String delimiter) {
public DescribeTableResponse describeTable(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest you to split this file into small ones according to the different operations. As you continue to add more operations, this file will be too large to maintain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split it into three files

Copy link
Copy Markdown
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@yuqi1129 yuqi1129 merged commit 32d9642 into apache:branch-lance-namepspace-dev Nov 5, 2025
26 checks passed
@yuqi1129 yuqi1129 deleted the issue_9015 branch November 5, 2025 13:47
jerryshao pushed a commit to jerryshao/gravitino that referenced this pull request Nov 11, 2025
… table operations (apache#9016)

### What changes were proposed in this pull request?

Add ITs for lance rest service and test lance table operations.

### Why are the changes needed?

To make code robust

Fix: apache#9015

### Does this PR introduce _any_ user-facing change?

N/A.

### How was this patch tested?

It's self a test.
youngyjd pushed a commit to youngyjd/gravitino that referenced this pull request Nov 21, 2025
… table operations (apache#9016)

### What changes were proposed in this pull request?

Add ITs for lance rest service and test lance table operations.

### Why are the changes needed?

To make code robust

Fix: apache#9015

### Does this PR introduce _any_ user-facing change?

N/A.

### How was this patch tested?

It's self a test.
youngyjd pushed a commit to youngyjd/gravitino that referenced this pull request Nov 21, 2025
… table operations (apache#9016)

### What changes were proposed in this pull request?

Add ITs for lance rest service and test lance table operations.

### Why are the changes needed?

To make code robust

Fix: apache#9015

### Does this PR introduce _any_ user-facing change?

N/A.

### How was this patch tested?

It's self a test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upload log Always upload container log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants